package per.hnvcam.searchext.data.dao.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import per.hnvcam.searchext.data.dao.ConfigDAO;
import per.hnvcam.searchext.data.model.Config;

@Service("ConfigDAO")
@Transactional
public class ConfigDAOImpl extends BaseDAOImpl implements ConfigDAO {
   @SuppressWarnings("rawtypes")
   @Override
   public List listAll() {
      return getHibernateTemplate().find("from Config");
   }

   @Override
   public Config findById(long id) {
      @SuppressWarnings("rawtypes")
      List result = getHibernateTemplate().find("from Config cfg where cfg.id = ?", id);
      if (result != null && result.size() > 0) {
         return (Config) result.get(0);
      }
      return null;
   }

   @Override
   public Config findByProperty(String property) {
      @SuppressWarnings("rawtypes")
      List result = getHibernateTemplate().find("from Config cfg where cfg.property = ?", property);
      if (result != null && result.size() > 0) {
         return (Config) result.get(0);
      }
      return null;
   }

   @Override
   public void save(Config config) {
      getHibernateTemplate().save(config);
   }

   @Override
   public void saveOrUpdate(Config config) {
      getHibernateTemplate().saveOrUpdate(config);
   }
}
